#include <bits/stdc++.h>

using namespace std;

int main()
{
    vector<pair<int, int>> nums({{1, 3}, {3, 4}, {3, 5}, {5, 5}});
    sort(nums.begin(), nums.end(), [](const pair<int, int> &x, const pair<int, int> &y)
         { return x.first < y.first; });
    for (auto num : nums)
        cout << num.first << " ";
    cout << endl; // 1 3 3 5
    auto it = lower_bound(nums.begin(), nums.end(), 3, [](const pair<int, int> &x, int v)
                          { return v > x.first; });
    int idx = distance(nums.begin(), it);
    cout << idx << endl; // 1
    auto it_upper = upper_bound(nums.begin(), nums.end(), 3, [](int v, const pair<int, int> &x)
                                { return v < x.first; });
    int idx_upper = distance(nums.begin(), it_upper);
    cout << idx_upper << endl; // 3
    return 0;
}
